import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'kiosk_model.dart';
import 'kiosk_model_platform_interface.dart';
import 'package:stream_transform/stream_transform.dart';

const _channel = MethodChannel('com.chihiro.kiosk_model');

/// An implementation of [KioskModelPlatform] that uses method channels.
class MethodChannelKioskModel extends KioskModelPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = _channel;

  @override
  Future<bool> startKioskMode() async {
    final result = await methodChannel.invokeMethod<bool>('startKioskMode');
    return result ?? false;
  }

  @override
  Future<bool> stopKioskMode() async {
    final result = await methodChannel.invokeMethod<bool>('stopKioskMode');
    return result ?? false;
  }

  @override
  Future<bool> owner() async {
    return await methodChannel.invokeMethod<bool>('owner') ?? false;
  }

  @override
  Future<bool> hideNavigationBar(bool disableNavigationBar) async {
    return await methodChannel.invokeMethod<bool>('hideNavigationBar',{"hideNavigationBar":disableNavigationBar}) ?? false;
  }
}
